﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using Workstation.ServiceModel.Ua;

namespace DeviceController.Wpf.ViewModels
{
    public class LedBackgroundValueConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is true)
            {
                return Brushes.Green;
            }

            return Brushes.Red;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is Brush brush && brush == Brushes.Green)
            {
                return true;
            }

            return false;
        }
    }

    //[Subscription("")]
    //: SubscriptionBase
    internal class ModeItemViewModel : SubscriptionBase
    {
        public ModeItemViewModel(Dictionary<string, string> opcMapDic)
        {
            base.InitializeComponent(new SubscriptionAttribute(endpointUrl: "opc.tcp://192.168.0.1:4840", 100), opcMapDic);
        }

        ///// <summary>
        ///// 编号，例如 1#，2#，3#。
        ///// </summary>x
        //[MonitoredItem(tagName: "123")]
        public string? Number { get; set; }

        /// <summary>
        /// 设定温度。
        /// </summary>
        public float TargetTemperature { get; set; }

        /// <summary>
        /// 当前温度。
        /// </summary>
        public float CurrentTemperature { get; set; }

        /// <summary>
        /// 是否打开红外灯管。
        /// </summary>
        public bool IsOpenLed { get; set; }

        /// <summary>
        /// 圆跳动数据。
        /// </summary>
        public float CircleData { get; set; }

        /// <summary>
        /// 测量温度。
        /// </summary>
        public float MeasureTemperature { get; set; }

        /// <summary>
        /// 灯管坐标。
        /// </summary>
        public int XAxis { get; set; }
    }
}
